home *** CD-ROM | disk | FTP | other *** search
- Path: titan.fullerton.edu!grosin
- From: grosin@titan.fullerton.edu (Gil Rosin)
- Newsgroups: comp.lang.c++
- Subject: What is referencing good for?
- Date: 25 Feb 1996 04:29:33 GMT
- Organization: California State University at Fullerton
- Message-ID: <4goojd$a9g@wintermute.ecs.fullerton.edu>
- NNTP-Posting-Host: titan.ecs.fullerton.edu
- X-Newsreader: TIN [version 1.2 PL2]
-
- I've been playing with referencing all day, and I can not find one use for it
- that I can not do with pointers. What is referencing good for? I know about
- reference parameters and I know about reference functions.
-
- The only pro I found about reference parameters is that it gives cleaner code,
- ie, with pointers you get:
-
- main()
- {
- int a;
- T(&a);
- }
-
- T(int *a)
- {
- *a = 6;
- }
-
- while with referencing you get:
-
- main()
- {
- int a;
- T(a);
- }
-
- T(int &a)
- {
- a = 6;
- }
-
- Aside from that, I found referencing to have the same uses as pointers, if I
- need to pass huge objects I can pass the address instead of the entire data,
- but I can do this with pointers as well.
-
- I don't quite understand what reference functions are good for. Again, I can
- do the same stuff with pointers.
-
- Can someone give me a REAL world example of where I would use referencing
- perhaps somewhere that I can not use pointers?
-
- And keep in mind that I'm a newbie, I'm just trying to learn the basics
- right now.
-
- Thanks, please reply via email to grosin@titan.fullerton.edu
-
-
-